# -*- encoding=utf8 -*-
__author__ = "hyq"

from airtest.core.api import *
from poco.drivers.android.uiautomation import AndroidUiautomationPoco
from airtest.core.android.android import *

def sendweixin(message):
    poco = AndroidUiautomationPoco(use_airtest_input=True, screenshot_each_action=False)
    #dev = connect_device('Android:///192.168.8.102:7555')
    dev = connect_device('Android:///3HX5T16B29007993')
    poco = AndroidUiautomationPoco(dev)
    keyevent("HOME")
    start_app('com.tencent.mm')
    poco(text="微信").click()
    time.sleep(2)
    #poco(text="黄永勤").click()
    poco(text="急停分析结果").click()
    poco("com.tencent.mm:id/ajs").click()
    mess = message.split()
    for m in mess:
        text(m,enter=False)
        keyevent("ENTER")
    poco(text="发送").click()
    keyevent("BACK")
    keyevent("BACK")
    keyevent("BACK")
    auto_setup(__file__)
    
if __name__ == '__main__':
    sendweixin('{0}{1}{2}短暂停通告：{3}在过去10分钟内急停最多，有{4}次，请线长到现场处理。'.format('W10','白班','3月8日','卤检急停','11'))